//
//  ReminderCell.m
//  Reminders
//
//  Created by Nearsoft User on 8/2/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ReminderCell.h"
#import "DateStrings.h"

@implementation ReminderCell

@synthesize reminderText;
@synthesize reminderRepeat;
@synthesize reminderDay;
@synthesize reminderMonth;
@synthesize reminderYear;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

/**
 * Method name: setReminder
 * Description: Sets the labels of the cell with the reminder title and date
 * Parameters: newReminder: the reminder used to fill the cell data
 */
- (void)setReminder:(Reminder *)aReminder
{
    DateStrings *dateString = [[DateStrings alloc] init];

    // Fill the labels from the cell with the reminder info
    self.reminderText.text = aReminder.title;
    self.reminderDay.text = [dateString getDayString:aReminder.date];
    self.reminderMonth.text = [dateString getMonthString:aReminder.date];
    self.reminderYear.text = [dateString getYearString:aReminder.date];

    switch ([aReminder repeat])
    {
                // Every Day
        case 1: self.reminderRepeat.text = [NSString stringWithFormat:@"Every day at %@", [dateString stringFromTime:aReminder.date]];
                break;
                // Every Week on the same Day
        case 2: self.reminderRepeat.text = [NSString stringWithFormat:@"Every week at %@", [dateString stringFromTime:aReminder.date]];
                break;
                // Every Month on the same Day
        case 3: self.reminderRepeat.text = [NSString stringWithFormat:@"Every month at %@", [dateString stringFromTime:aReminder.date]];
                break;
                //Just Once
        default: self.reminderRepeat.text = [NSString stringWithFormat:@"Once at %@", [dateString stringFromTime:aReminder.date]];
                break;
    }
}

@end